//
//  BannerTableViewCell.m
//  huien
//
//  Created by yiban on 2017/5/26.
//  Copyright © 2017年 lcb. All rights reserved.
//

#import "BannerTableViewCell.h"
#import "HomeModel.h"
#import "BannerModel.h"
@interface BannerTableViewCell()
{
    
}
@property(nonatomic,strong)UIView *backgroupView;
@property(nonatomic,strong)UIView *hView;
@property(nonatomic,strong)UIView *vView;
@property(nonatomic,strong)UILabel *amoutLabelK;
@property(nonatomic,strong)UILabel *amoutLabelV;
@property(nonatomic,strong)UILabel *amoutLabelU;
@property(nonatomic,strong)UILabel *numberLabelK;
@property(nonatomic,strong)UILabel *numberLabelV;
@property(nonatomic,strong)UILabel *numberLabelU;
@end
@implementation BannerTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.bannerView = [[LcbAutomaticScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
        self.bannerView.pageControlInTheMiddle = YES;
        [self.contentView addSubview:self.bannerView];
        self.backgroupView.frame =CGRectMake(0, 200, SCREEN_WIDTH, 40);
        self.vView.frame=CGRectMake(SCREEN_WIDTH/2-0.5, 10, 1, 20);
        self.hView.frame=CGRectMake(0, 39, SCREEN_WIDTH, 1);
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model indexPath:(NSIndexPath *)indexPath
{
    self.data =model;
    self.indexPath=indexPath;
    Home2Model *homemodel = (Home2Model*)model;
    NSMutableArray *temArray = [NSMutableArray array];
    for (BannerModel *bmodel in homemodel.banners) {
        if (bmodel.imageUrl.length>0) {
             [temArray addObject:bmodel.imageUrl];
        }
    }
    self.bannerView.imagesUrl = temArray;
    InvestModel *invest = homemodel.invest;
    NSString *ak =@"累计投资金额: ";
    CGFloat wight1 = [ak widthForFont:self.amoutLabelK.font];
    self.amoutLabelK.frame =CGRectMake(10, (40-15)/2, wight1, 15);
    NSString *av =invest.amount;
    CGFloat wight2 = [av widthForFont:self.amoutLabelV.font];
    
    self.amoutLabelV.frame =CGRectMake(self.amoutLabelK.frame.origin.x+self.amoutLabelK.frame.size.width+2, (40-20)/2, wight2, 20);
    self.amoutLabelV.text = av;
    NSString *au =invest.amountUnit;
    CGFloat wight3 = [au widthForFont:self.amoutLabelV.font];
    self.amoutLabelU.frame =CGRectMake(self.amoutLabelV.frame.origin.x+self.amoutLabelV.frame.size.width+2, (40-20)/2, wight3, 20);
    self.amoutLabelU.text = au;
    //
    
    
    NSString *nu =invest.numberUnit;
    CGFloat wight6 = [nu widthForFont:self.numberLabelV.font];
    self.numberLabelU.frame =CGRectMake(SCREEN_WIDTH-wight6-10, (40-20)/2, wight6, 20);
    self.numberLabelU.text = nu;
    //
    NSString *nv =invest.number;
    CGFloat wight5 = [nv widthForFont:self.numberLabelV.font];
    self.numberLabelV.frame =CGRectMake(self.numberLabelU.frame.origin.x-wight5-2, (40-20)/2, wight5, 20);
    self.numberLabelV.text = nv;
    //
    NSString *nk =@"累计投资人次: ";
    CGFloat wight4 = [nk widthForFont:self.numberLabelK.font];
    self.numberLabelK.frame =CGRectMake(self.numberLabelV.frame.origin.x-wight4-2, (40-15)/2,wight4, 15);
}
+(CGFloat)returnCellHeight
{
    return 240;
}
-(void)dealloc
{
    [LcbLog log:@"BannerTableViewCell--------->dealloc"];
}
-(UIView*)backgroupView
{
    if (!_backgroupView) {
        _backgroupView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 40)];
        _backgroupView.backgroundColor=[UIColor whiteColor];
        [self addSubview:_backgroupView];
    }
    return _backgroupView;
}
-(UIView*)hView
{
    if (!_hView) {
        _hView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 1)];
        _hView.backgroundColor=linecolor;
        [_backgroupView addSubview:_hView];
    }
    return _hView;
}
-(UIView*)vView
{
    if (!_vView) {
        _vView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 1)];
        _vView.backgroundColor=UIColorFromRGB(0xdddddd);
        [_backgroupView addSubview:_vView];
    }
    return _vView;
}
-(UILabel*)amoutLabelK
{
    if (!_amoutLabelK) {
        _amoutLabelK = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _amoutLabelK.text = @"累计投资金额:";
        _amoutLabelK.font = [UIFont boldSystemFontOfSize:12];
        _amoutLabelK.textColor = UIColorFromRGB(0x666666);
        _amoutLabelK.textAlignment = NSTextAlignmentLeft;
        _amoutLabelK.backgroundColor = [UIColor clearColor];
        _amoutLabelK.lineBreakMode = NSLineBreakByClipping;
        _amoutLabelK.numberOfLines = 1;
        [self.backgroupView addSubview:_amoutLabelK];
    }
    return _amoutLabelK;
}
-(UILabel*)amoutLabelV
{
    if (!_amoutLabelV) {
        _amoutLabelV = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _amoutLabelV.text = @"";
        _amoutLabelV.font = [UIFont boldSystemFontOfSize:12];
        _amoutLabelV.textColor =  UIColorFromRGB(0xeb9a1a);
        _amoutLabelV.textAlignment = NSTextAlignmentLeft;
        _amoutLabelV.backgroundColor = [UIColor clearColor];
        _amoutLabelV.lineBreakMode = NSLineBreakByClipping;
        _amoutLabelV.numberOfLines = 1;
        [self.backgroupView addSubview:_amoutLabelV];
    }
    return _amoutLabelV;
}
-(UILabel*)amoutLabelU
{
    if (!_amoutLabelU) {
        _amoutLabelU = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _amoutLabelU.text = @"";
        _amoutLabelU.font = [UIFont boldSystemFontOfSize:12];
        _amoutLabelU.textColor =  UIColorFromRGB(0x666666);
        _amoutLabelU.textAlignment = NSTextAlignmentLeft;
        _amoutLabelU.backgroundColor = [UIColor clearColor];
        _amoutLabelU.lineBreakMode = NSLineBreakByClipping;
        _amoutLabelU.numberOfLines = 1;
        [self.backgroupView addSubview:_amoutLabelU];
    }
    return _amoutLabelU;
}
-(UILabel*)numberLabelK
{
    if (!_numberLabelK) {
        _numberLabelK = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _numberLabelK.text = @"累计投资人次:";
        _numberLabelK.font = [UIFont boldSystemFontOfSize:12];
        _numberLabelK.textColor = UIColorFromRGB(0x666666);
        _numberLabelK.textAlignment = NSTextAlignmentLeft;
        _numberLabelK.backgroundColor = [UIColor clearColor];
        _numberLabelK.lineBreakMode = NSLineBreakByClipping;
        _numberLabelK.numberOfLines = 1;
        [self.backgroupView addSubview:_numberLabelK];
        
    }
    return _numberLabelK;
}
-(UILabel*)numberLabelV
{
    if (!_numberLabelV) {
        _numberLabelV = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _numberLabelV.text = @"";
        _numberLabelV.font = [UIFont boldSystemFontOfSize:12];
        _numberLabelV.textColor =  UIColorFromRGB(0xeb9a1a);
        _numberLabelV.textAlignment = NSTextAlignmentLeft;
        _numberLabelV.backgroundColor = [UIColor clearColor];
        _numberLabelV.lineBreakMode = NSLineBreakByClipping;
        _numberLabelV.numberOfLines = 1;
        [self.backgroupView addSubview:_numberLabelV];
        
    }
    return _numberLabelV;
}
-(UILabel*)numberLabelU
{
    if (!_numberLabelU) {
        _numberLabelU = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 20)];
        _numberLabelU.text = @"";
        _numberLabelU.font = [UIFont boldSystemFontOfSize:12];
        _numberLabelU.textColor =  UIColorFromRGB(0x666666);
        _numberLabelU.textAlignment = NSTextAlignmentLeft;
        _numberLabelU.backgroundColor = [UIColor clearColor];
        _numberLabelU.lineBreakMode = NSLineBreakByClipping;
        _numberLabelU.numberOfLines = 1;
        [self.backgroupView addSubview:_numberLabelU];
        
    }
    return _numberLabelU;
}
@end
